import Message from './Message.vue'
import Vue from 'vue'

// 获取message组件的构造函数，构造message组件
const messageConstructor = Vue.extend(Message)

const messageServe = (message)=> {
    // 创建message实例
    const instance = new messageConstructor()
    // 将组件挂载到指定元素
    instance.$mount(document.createElement('div'))
    // 将组件挂载的元素添加到body的元素下
    document.body.appendChild(instance.$el)
    // 将传递过来的参数赋值给指定对象
    instance.message = message.message;
    instance.desc = message.desc;
    // 显示弹出框
    Vue.nextTick(()=> {
        instance.visible = true
        setTimeout(() => {
            instance.visible = false;
        }, 2000);
    })
    return instance
}

export default messageServe